This notebook takes in exported CellProfiler data along with a metadata table with information about treatment for each mouse and outputs graphs and statistics about the fibers.
Setup
library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.1.2
library(here)
here() starts at /Users/rsenft/Documents/GitHub/RebeccaSenft_Projects/002_Dymecki_neuro/Batch_3_fibers/Fibers_analysis
library(dplyr)
Warning: package 'dplyr' was built under R version 4.1.2
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
library(RColorBrewer)
Warning: package 'RColorBrewer' was built under R version 4.1.2
library(readr)
Warning: package 'readr' was built under R version 4.1.2
library(DT)
Warning: package 'DT' was built under R version 4.1.2
Get data
Note that the CSV had to be corrected because there is one filename with ROB instead of ROb and because not all the metadata is extracted correctly (inconsistent filenames), so I manually corrected this in Excel using Flash Fill and correcting the mispelling and saved this as Tph2_Per_Image_metadata_corrected.csv.
path_to_csv_folder =here("csvs")save_path <- path_to_csv_folderimg_filename="Tph2_Per_Image_metadata_corrected.csv"sc_filename="Tph2_Per_BorderedCells.csv"metadata_filename="Litter-groups-A-through-ii.csv"#note I gave this headings#load data and metadata for imagesimage_df <-read.csv(here(path_to_csv_folder,img_filename), check.names=FALSE)metadata <-read.csv(here(path_to_csv_folder,metadata_filename), check.names =FALSE)image_df_combined <-merge(image_df, metadata, by.x="Image_Metadata_Litter", by.y="Litter")#load data for single cellssc_df <-read.csv(here(path_to_csv_folder,sc_filename), check.names=FALSE)sc_df_combined <-merge(sc_df, image_df_combined, by="ImageNumber")
We also need to compute the average length of a branch, taken as the total skeleton length / (number of trunks + number of non-trunk branches).
Now we apply that function to each of the 5 variables we want to plot:
p_list=list()for (i in1:length(measurements)) { p_list[[i]] <-plot_boxwhisker(region_df, measurements, desc, i, x_var="Image_Metadata_Region")plot(p_list[[i]])}
(a)
(b)
(c)
(d)
(e)
Figure 1: No effect of experimental group on fiber measures.
In examining Mean Process Length, it almost looks like there could be a difference associated with experimental group in R4. We can look at this further by conducting a t-test. RA and IH are not statistically different:
Welch Two Sample t-test
data: grp1 and grp2
t = -1.8325, df = 22.148, p-value = 0.08035
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-3.361794 0.207057
sample estimates:
mean of x mean of y
15.60552 17.18289
Now let’s just look overall at RA vs. IH mice:
p_list=list()for (i in1:length(measurements)) { p_list[[i]] <-plot_boxwhisker(total_df, measurements, desc, i, x_var="ExpGroup")plot(p_list[[i]])}#cowplot::plot_grid(plotlist=p_list, ncol=2, scale=1)
(a)
(b)
(c)
(d)
(e)
Figure 2: No effect of experimental group on fiber measures.
Instead of viewing each animal as a datapoint, we can also look at the distribution of all cells. Here’s our plotting function: